﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace University.Workshop.Presenters.Person.Read
{
    public class PresenterReadPerson
    {
        IReadPersonView view;
        Model.Person personToShow = new Model.Person();
        public PresenterReadPerson(IReadPersonView view, Model.Person person)
        {
            this.view = view;
            this.personToShow.PersonId = person.PersonId;
            this.personToShow.Names = person.Names != null? person.Names : string.Empty;
            this.personToShow.LastNames = person.LastNames != null? person.LastNames : string.Empty;
            this.personToShow.Phone = person.Phone != null ? person.Phone : string.Empty;
        }

        public void FillViewData()
        {
            view.PersonId = personToShow.PersonId;
            view.PersonNames = personToShow.Names;
            view.PersonLastNames = personToShow.LastNames;
            view.PersonPhones = personToShow.Phone.Split(',').Where(x => x != string.Empty).ToList();
        }
    }
}
